<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:if test="${playerQuery.message != null}">
	<script type=text/javascript>
	  <!--		  
	  	  alert("${playerQuery.message}");
		  window.location = "${playerQuery.location}"		  
	  //-->
	</script>
</c:if>

<c:if test="${playerMap.module=='viewPhoto'}">
<h2>Upload Photo</h2>
<hr/>
Id Player = ${playerMap.playerId}<br>
Link      = ${playerMap.link}<br>
</c:if>

<!-- 
<c:if test="${teamMapAttribute.modulePlayerMap=='photo'}">
<h2>Upload Photo</h2>
<hr/>
<form name="formUpload" method="post" action="uploadPhoto.htm">
	<input type="hidden" name="playerId" value="${teamMapAttribute.playerId}">
	<table>
		<tr>
			<td>Upload Photo</td>
			<td>:</td>
			<td><input type="file" name="file"></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td><input type="submit" name="upload" value="Upload"/></td>
		</tr>
	</table>
</form>
</c:if>
 -->
 
<c:if test="${teamMapAttribute.modulePlayerMap=='list'}">
<h2>List Team Football</h2>
<hr />
<table border="1" width="350px">
	<tr>
		<th width="10%" bgcolor="#0000CC"><font color="#FFFFFF"><b>No</b></font></th>
		<th width="60%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Team Name</b></font></th>
		<th width="30%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Action</b></font></th>		
	</tr>
	<c:forEach items="${teamMapAttribute.teamListMap}" var="team" varStatus="teamCount">
	<tr>
	    <c:if test="${teamCount.count % 2 == 0}">
	    	<td align="center" bgcolor="#C1E0FF">${teamCount.count}</td>
			<td align="left" bgcolor="#C1E0FF">${team.name}</td>
			<td align="center" bgcolor="#C1E0FF">
			    <a href="playerManage.htm?teamId=${team.id}">Manage</a> 			    
			</td>
	    </c:if>
	    <c:if test="${teamCount.count % 2 == 1}">
	    	<td align="center" bgcolor="#E1F0FF">${teamCount.count}</td>
			<td align="left" bgcolor="#E1F0FF">${team.name}</td>
			<td align="center" bgcolor="#E1F0FF">
			    <a href="playerManage.htm?teamId=${team.id}">Manage</a> 			    
			</td>
	    </c:if>
	</tr>
	</c:forEach>
</table>
</c:if>

<c:if test="${playerMap.module=='manage'}">
<h2>Manage Team : ${playerMap.teamPlayer}</h2>
<hr/>
 
<h2><u>Player Name</u></h2>
<table border="1" width="500px">
	<tr>
		<th width="10%" bgcolor="#0000CC"><font color="#FFFFFF"><b>No</b></font></th>
		<th width="50%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Player Name</b></font></th>
		<th width="25%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Action</b></font></th>				
	</tr>
	<c:forEach items="${playerMap.listPlayer}" var="player" varStatus="playerCount">
	<tr>
	    <c:if test="${playerCount.count % 2 == 0}">
	    	<td align="center" bgcolor="#C1E0FF">${playerCount.count}</td>
			<td align="left" bgcolor="#C1E0FF">${player.firstName} ${player.lastName}</td>
			<td align="center" bgcolor="#C1E0FF">
				<a href="playerEditP.htm?playerId=${player.playerId}">Edit</a> |
			    <a href="playerDelete.htm?playerId=${player.playerId}&teamId=${playerMap.teamIdPlayer}" onClick="return confirm('Are you sure to delete this data?')">Delete</a> |
			    <a href="playerPhoto.htm?playerId=${player.playerId}">Upload</a>
			</td>
	    </c:if>
	    <c:if test="${playerCount.count % 2 == 1}">
	    	<td align="center" bgcolor="#E1F0FF">${playerCount.count}</td>
			<td align="left" bgcolor="#E1F0FF">${player.firstName} ${player.lastName}</td>			
			<td align="center" bgcolor="#E1F0FF">
				<a href="playerEditP.htm?playerId=${player.playerId}">Edit</a> |
			    <a href="playerDelete.htm?playerId=${player.playerId}&teamId=${playerMap.teamIdPlayer}" onClick="return confirm('Are you sure to delete this data?')">Delete</a> |
			    <a href="playerPhoto.htm?playerId=${player.playerId}">Upload</a>
			</td>
	    </c:if>
	</tr>
	</c:forEach>
</table>
<p></p>
<h2><u>Reserve Name</u></h2>
<table border="1" width="500px">
	<tr>
		<th width="10%" bgcolor="#0000CC"><font color="#FFFFFF"><b>No</b></font></th>
		<th width="50%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Reserve Name</b></font></th>
		<th width="25%" bgcolor="#0000CC"><font color="#FFFFFF"><b>Action</b></font></th>				
	</tr>
	<c:forEach items="${playerMap.listReserve}" var="reserve" varStatus="reserveCount">
	<tr>
	    <c:if test="${reserveCount.count % 2 == 0}">
	    	<td align="center" bgcolor="#C1E0FF">${reserveCount.count}</td>
			<td align="left" bgcolor="#C1E0FF">${reserve.firstName} ${reserve.lastName}</td>
			<td align="center" bgcolor="#C1E0FF">
			    <a href="playerEditR.htm?playerId=${reserve.playerId}">Edit</a> |
			    <a href="playerDelete.htm?playerId=${reserve.playerId}&teamId=${playerMap.teamIdPlayer}" onClick="return confirm('Are you sure to delete this data?')">Delete</a> |
			    <a href="playerPhoto.htm?playerId=${reserve.playerId}">Upload</a>
			</td>
	    </c:if>
	    <c:if test="${reserveCount.count % 2 == 1}">
	    	<td align="center" bgcolor="#E1F0FF">${reserveCount.count}</td>
			<td align="left" bgcolor="#E1F0FF">${reserve.firstName} ${reserve.lastName}</td>
			<td align="center" bgcolor="#E1F0FF">
			    <a href="playerEditR.htm?playerId=${reserve.playerId}">Edit</a> |
			    <a href="playerDelete.htm?playerId=${reserve.playerId}&teamId=${playerMap.teamIdPlayer}" onClick="return confirm('Are you sure to delete this data?')">Delete</a> |
			    <a href="playerPhoto.htm?playerId=${reserve.playerId}">Upload</a>
			</td>
	    </c:if>
	</tr>
	</c:forEach>
</table>
<p></p>
<a href="<c:url value='/playerForm.htm?teamId=${playerMap.teamIdPlayer}&type=player'/>"><b>Add Player</b></a> | 
<a href="<c:url value='/playerForm.htm?teamId=${playerMap.teamIdPlayer}&type=reserve'/>"><b>Add Reserve</b></a> |
<a href="<c:url value='/captain.htm?teamId=${playerMap.teamIdPlayer}'/>"><b>Captain</b></a> |
</c:if>

<c:if test="${playerMap.module=='add'}">
<h2>Add New Player</h2>
<hr/>
<form action="player.htm" method="post">
	<input type="text" name="teamId" value="${playerMap.teamId}">
	<input type="text" name="type" value="${playerMap.type}">
	<table>	
		<tr>
			<td>First Name</td>
			<td>:</td>
			<td><input type="text" name="firstName" value=""></td>
		</tr>
		<tr>
			<td>Last Name</td>
			<td>:</td>
			<td><input type="text" name="lastName" value=""></td>
		</tr>
		<tr>
			<td>
				<c:if test="${playerMap.type=='player'}">
					Salary
				</c:if>				
				<c:if test="${playerMap.type=='reserve'}">
					Commission
				</c:if>
			</td>
			<td>:</td>
			<td><input type="text" name="salary" value=""></td>
		</tr>
		<!-- 
		<tr>
			<td>Player Status</td>
			<td>:</td>
			<td>			
				<input type="radio" name="reserve" value="player" checked="checked"/>Player
				<input type="radio" name="reserve" value="reserve" />Reserve
			</td>
		</tr>
		 -->
		<tr>
			<td></td>
			<td></td>
			<td>
				<input type="submit" name="save" value="Save" onClick="return confirm('Are you sure to save this data?')"/>
				<input type="button" name="cancel" value="Cancel" onClick="javascript:history.back(1)"/>
			</td>
		</tr>
	</table>
</form>
</c:if>

<c:if test="${playerMap.module=='edit'}">
<h2>Edit Player</h2>
<hr/>
<form action="playerEdit.htm" method="post">
	<input type="hidden" name="playerId" value="${playerMap.playerId}">
	<input type="hidden" name="teamId" value="${playerMap.teamId}">
	<table>	
		<tr>
			<td>First Name</td>
			<td>:</td>
			<td><input type="text" name="firstName" value="${playerMap.firstName}"></td>
		</tr>
		<tr>
			<td>Last Name</td>
			<td>:</td>
			<td><input type="text" name="lastName" value="${playerMap.lastName}"></td>
		</tr>
		<tr>
			<c:if test="${playerMap.honor>0}">
			<td>Salary</td>
			<td>:</td>
			<td><input type="text" name="salary" value="${playerMap.honor}"></td>
			</c:if>
			<c:if test="${playerMap.honor2>0}">
			<td>Commission</td>
			<td>:</td>
			<td><input type="text" name="salary" value="${playerMap.honor2}"></td>
			</c:if>
		</tr>
		<tr>
			<td>Player Status</td>
			<td>:</td>
			<td>			
				<input type="radio" name="type" value="player" <c:if test="${playerMap.reserve==0}">checked="checked"</c:if>/>Player
				<input type="radio" name="type" value="reserve" <c:if test="${playerMap.reserve==1}">checked="checked"</c:if>/>Reserve
			</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td>
				<input type="submit" name="edit" value="Edit" onClick="return confirm('Are you sure to edit this data?')"/>
				<input type="button" name="cancel" value="Cancel" onClick="javascript:history.back(1)"/>
			</td>
		</tr>
	</table>
</form>
</c:if>